from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from goods.models import SPUSpecification
from meiduo_admin.serializers.specs import SPUSpecificationSerializer,SPUSerializer
from meiduo_admin.utils import UserPageNum
from goods.models import SPU


class SpecsView(ModelViewSet):
    '''
    商品规格的增删改查
    '''

    serializer_class = SPUSpecificationSerializer
    #  指定查询集
    queryset = SPUSpecification.objects.all()
    pagination_class = UserPageNum

    def simple(self, request):
        """
        获取SPU商品
        :param request:
        :return:
        """
        spus = SPU.objects.all()
        ser = SPUSerializer(spus,many=True)

        return Response(ser.data)